import 'package:flutter/material.dart';

class HomeNav extends StatelessWidget {
  HomeNav({super.key});

// 导航数据
  final List navList = [
    {
      'title': '我的房屋',
      'icon': 'assets/images/house_nav_icon@2x.png',
    },
    {
      'title': '我的报修',
      'icon': 'assets/images/repair_nav_icon@2x.png',
    },
    {
      'title': '访客登记',
      'icon': 'assets/images/visitor_nav_icon@2x.png',
    }
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      width: MediaQuery.of(context).size.width,
      // 外边距
      margin: const EdgeInsets.only(top: 16, bottom: 16),
      // 内边距
      padding: EdgeInsets.only(top: 16, bottom: 16),
      // 圆角
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Row(
        children: navList.map((item) {
          return Expanded(
              flex: 1,
              child: GestureDetector(
                onTap: () {
                  print(item);
                  if (item['title'] == '我的房屋') {
                    Navigator.pushNamed(context, '/homeList');
                  }
                },
                child: Column(
                  children: [
                    Image.asset(
                      item['icon'],
                      width: 30,
                      height: 30,
                    ),
                    Text(
                      item['title'],
                      style: TextStyle(fontSize: 12),
                    )
                  ],
                ),
              ));
        }).toList(),
      ),
    );
  }
}


// homeNavItems() {
// return 
// }